package com.zeng.stpro.modules.app.controller;

import com.zeng.stpro.commons.controller.AbstractBaseController;
import com.zeng.stpro.commons.utils.R;
import com.zeng.stpro.modules.app.bean.SysUser;
import com.zeng.stpro.modules.app.service.SysUserRoleService;
import com.zeng.stpro.modules.app.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author ZENGZHIJUN
 * @Date 2021/2/2 17:05
 */
@RestController
@RequestMapping(value = "/api/admin/user")
public class SysUserController extends AbstractBaseController {

    @Autowired
    private SysUserService sysUserService;
    @Autowired
    private SysUserRoleService sysUserRoleService;

    @GetMapping(value = "/roles/{id}")
    public R findRolesByUserId(@PathVariable Long id) {
        List<Long> roleids = sysUserRoleService.findRoleIdListByUserId(id);
        return R.ok().data("roles", roleids);
    }

    @GetMapping(value = "/{page}/{size}")
    public R list(@PathVariable Long page, @PathVariable Long size) {
        List<SysUser> pagelist = sysUserService.findPageList(page, size);
        return R.ok().data("list", pagelist);
    }


}
